package com.wonders.controller;
import com.wonders.dto.Result;
import com.wonders.service.IShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * 功能描述:店铺相关的信息
 * @Author: yyalin
 * @CreateDate: 2023/8/17 16:52
 */
@Api(tags="店铺相关业务操作")
@RestController
@RequestMapping("/shop")
public class ShopController {

    @Resource
    public IShopService shopService;
    /**
     * 功能描述:将商店的信息批量添加到redis中
     * @MethodName: shopDataToRedis
     * @MethodParam: []
     * @Return: com.wonders.dto.Result
     * @Author: yyalin
     * @CreateDate: 2023/8/17 17:15
     */
    @ApiOperation(value="将商店的信息批量添加到redis中", notes="shopDataToRedis")
    @GetMapping("/shopDataToRedis")
    public Result shopDataToRedis(){
        shopService.shopDataToRedis();
        return Result.ok();
    }

    /**
     * 功能描述:根据商铺类型基于redis的Geo实现附近商铺分页查询
     * @MethodName: queryShopByType
     * @MethodParam: [typeId, current:当前页数, x, y]
     * @Return: com.wonders.dto.Result
     * @Author: yyalin
     * @CreateDate: 2023/8/17 17:00
     */
    @ApiOperation(value="根据商铺类型基于Redis的Geo实现附近商铺分页查询", notes="queryShopByType")
    @GetMapping("/of/type")
    public Result queryShopByType(
            @RequestParam("typeId") Integer typeId,
            @RequestParam(value = "current", defaultValue = "1") Integer current,
            @RequestParam(value = "x", required = false) Double x,
            @RequestParam(value = "y", required = false) Double y
    ) {
       return shopService.queryShopByType(typeId, current, x, y);
    }


}
